package com.itheima.controller;

import com.itheima.domain.R;
import com.itheima.domain.Sample;
import com.itheima.service.SampleService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
public class SampleController {

    @Autowired
    private SampleService sampleService;


    @PostMapping("/sample/add")
    public R<Boolean> add(@RequestBody Sample sample){
        return R.success(sampleService.save(sample));
    }


    @GetMapping("sample/{id}")
    public R<Boolean> delete(@PathVariable String id){
        return R.success(sampleService.removeById(id));
    }

    @PutMapping("sample/update")
    public R<Boolean> update(@RequestBody Sample sample){
        return R.success(sampleService.updateById(sample));
    }

    @GetMapping("sample/select")
    public R<Sample> select(String id){
        return R.success(sampleService.getById(id));
    }



}
